package DBLayer;

import static org.junit.Assert.*;

import java.sql.Date;
import java.sql.Time;
import java.util.ArrayList;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import ModelLayer.Booking;
import ModelLayer.Employee;
import ModelLayer.Person;
import ModelLayer.Treatment;

public class DBBookingTest {
	private IFDBBooking dbBook;
	
	@Before
	public void setUp() throws Exception {
		dbBook = new DBBooking();
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testGetEmpBookingsByDate() {
		try
		{
			ArrayList<Booking> bookings = dbBook.getEmpBookingsByDate(1, new Date(113, 4, 11));
			
			if(bookings != null)
			{
				for(Booking book : bookings)
				{
					System.out.println(book.getId() + " " + book.getDate().toString() + " " + book.getStartTime().toString());
				}
			}
		}
		catch(Exception err)
		{
			fail("Not yet implemented");
		}	
	}

	@Test
	public void testInsertBooking() {
		try
		{
			Booking booking = new Booking();
			booking.setId(GetMax.getMaxId("SELECT MAX(ID) FROM Booking"));
			booking.setTreatment(new Treatment(1));
			booking.setHairDresser(new Employee(1));
			booking.setCustomer(new Person(2));
			booking.setDate(new Date(113, 4, 11));
			booking.setStartTime(new Time(13, 00, 00));
			booking.setEndTime(new Time(13, 30, 00));
			booking.setStatus("created");
			
			dbBook.insertBooking(booking);
		}
		catch(Exception err)
		{
			fail("Not yet implemented");
		}	
	}
	
	@Test
	public void testGetBookingByDates() {
		try
		{
			ArrayList<Booking> bookings = dbBook.getBookingsByDateToDate("2013-01-01", "2014-01-01");
			
			
			if(bookings != null)
			{
				for(Booking book : bookings)
				{
					System.out.println(book.getId() + " " + book.getDate().toString() + " " + book.getStartTime().toString());
				}
			}
		}
		catch(Exception err)
		{
			fail("Not yet implemented");
		}	
	}
}
